package com.cdp.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdp.common.core.domain.entity.*;
import com.cdp.system.dto.MechanicalPerformanceQueryDTO;
import com.cdp.system.mapper.SysCementMapper;
import com.cdp.system.mapper.SysMechanicalPerformanceMapper;
import com.cdp.system.service.*;
import com.cdp.system.vo.*;
import com.google.common.base.Function;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

@Service
public class SysMechanicalPerformanceServiceImpl extends ServiceImpl<SysMechanicalPerformanceMapper, SysMechanicalPerformance>implements ISysMechanicalPerformanceService {


    @Autowired
    private SysMechanicalPerformanceMapper sysMechanicalPerformanceMapper;

    @Autowired
    private SysCementMapper sysCementMapper;



    @Autowired
    private IsysRegionService isysRegionService;
    @Autowired
    private ISysFlyashService sysFlyashService;

    @Autowired
    private ISysSandFinenesService sysSandFinenesService;

    @Autowired
    private ISysSandTypeService sysSandTypeService;

    @Autowired
    private ISysSandService sysSandService;

    @Autowired
    private ISysStoneGrainService sysStoneGrainService;

    @Autowired
    private ISysFlyashTypeService sysFlyashTypeService;

    @Autowired
    private ISysFlyashFinenessService sysFlyashFinenessService;

    @Autowired
    private ISysWaterReducerTypeService sysWaterReducerTypeService;

    @Autowired
    private ISysCementService sysCementService;

    @Autowired
    private ISysStoneService sysStoneService;

    @Autowired
    private ISysWaterReducerService sysWaterReducerService;

    @Autowired
    private ISysStoneSizeService stoneSizeService;

    @Autowired
    private ISysSourceNameService sysSourceNameService;
    @Autowired
    private ISysEfficiencyMerchantNameService sysEfficiencyMerchantNameService;


    @Autowired
    private ISysDeformationPerformanceService sysDeformationPerformanceService;

    @Autowired
    private ISysEfficiencyAgentService sysEfficiencyAgent;

    @Autowired
    private ISysDurabilityPerformanceService sysDurabilityPerformanceService;

    @Autowired
    private ISysWaterService waterService;

    @Autowired
    private ISysMineralPowderService sysMineralPowderService;

    @Autowired
    private SysOtherAdmixturesService sysOtherAdmixturesService;


    @Autowired
    private ISysWaterModelService sysWaterModelService;

    @Autowired
    private ISysSwellingagentService sysSwellingagentService;


    @Override
    public List<SysMechanicalPerformance> listSysMechanicalPerformance() {
        List<SysMechanicalPerformance> list = list();
        return list;
    }




    @Override
    public List<MechanicalPerformanceQueryVO> queryMistedMechanicalPerformance(MechanicalPerformanceQueryDTO mechanicalPerformanceQueryDTO) {
        // Step 1: 调用 Mapper 获取查询结果
        List<MechanicalPerformanceQueryVO> mechanicalPerformanceList = sysMechanicalPerformanceMapper.selectByCondition(mechanicalPerformanceQueryDTO);


        // Step 2: 预加载相关数据，减少循环中查询，转换 Integer -> Long
        Map<Long, SysWater> waterMap = waterService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysWater -> sysWater.getWaterId().longValue(),
                        item -> item
                ));

        Map<Long, SysCement> cementMap = sysCementService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysCement -> sysCement.getCementId().longValue(),
                        item -> item
                ));

        Map<Long, SysStone> stoneMap = sysStoneService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysStone -> sysStone.getStoneId().longValue(),
                        item -> item
                ));

        Map<Long, SysSand> sandMap = sysSandService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysSand -> sysSand.getSandId().longValue(),
                        item -> item
                ));

        Map<Long, SysFlyash> flyashMap = sysFlyashService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysFlyash -> sysFlyash.getFlyashId().longValue(),
                        item -> item
                ));

        Map<Long, SysWaterReducer> reducerMap = sysWaterReducerService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysWaterReducer -> sysWaterReducer.getReducerId().longValue(),
                        item -> item
                ));


        Map<Long, SysEfficiencyAgent> efficiencyAgentMap = sysEfficiencyAgent.list()
                .stream()
                .collect(Collectors.toMap(
                        sysEfficiencyAgent -> sysEfficiencyAgent.getAgentId().longValue(),
                        item -> item
                ));

        Map<Long, SysMineralPowder> mineralPowderMap = sysMineralPowderService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysMineralPowder -> sysMineralPowder.getPowderId().longValue(),
                        item -> item
                ));

        Map<Long, SysOtherAdmixtures> otherAdmixturesMap = sysOtherAdmixturesService.list()
                .stream()
                .collect(Collectors.toMap(
                        sysOtherAdmixtures -> sysOtherAdmixtures.getAdmixturesId().longValue(),
                        item -> item
                ));

        Map<Long, SysSwellingagent> swellingagentMap = sysSwellingagentService.list()
                .stream()
                .collect(Collectors.toMap(
                        swellingagent -> swellingagent.getSwellingagentId().longValue(),
                        item -> item
                ));

        // Step 3: 填充数据
        List<MechanicalPerformanceQueryVO> mechanicalList = mechanicalPerformanceList.stream().map(entity -> {
            MechanicalPerformanceQueryVO vo = new MechanicalPerformanceQueryVO();
            BeanUtils.copyProperties(entity, vo);

            //矿粉量
            //其他参合料量
            //膨胀剂用量



            // 设置水数据
            if (entity.getWaterId() != null) {
                SysWater sysWater = waterMap.get(entity.getWaterId());
                if (sysWater != null) {
                    SysWaterVO sysWaterVO = new SysWaterVO();
                    BeanUtils.copyProperties(sysWater, sysWaterVO);
                    vo.setWaterModel(sysWater.getModel());
                    vo.setSysWaterVO(sysWaterVO);
                }
            }

            // 设置水泥数据
            if (entity.getCementId() != null) {
                SysCement sysCement = cementMap.get(entity.getCementId());
                if (sysCement != null) {
                    SysCementVO sysCementVO = new SysCementVO();
                    BeanUtils.copyProperties(sysCement, sysCementVO);
                    vo.setSysCementVO(sysCementVO);
                    vo.setCementModel(sysCementVO.getModel());
                }
            }

            // 设置石头数据
            if (entity.getStoneId() != null) {
                SysStone sysStone = stoneMap.get(entity.getStoneId());
                if (sysStone != null) {
                    SysStoneVO sysStoneVO = new SysStoneVO();
                    BeanUtils.copyProperties(sysStone, sysStoneVO);
                    vo.setSysStoneVO(sysStoneVO);
                    vo.setStoneModel(sysStoneVO.getModel());

                }
            }

            // 设置砂数据
            if (entity.getSandId() != null) {
                SysSand sysSand = sandMap.get(entity.getSandId());
                if (sysSand != null) {
                    SysSandVO sysSandVO = new SysSandVO();
                    BeanUtils.copyProperties(sysSand, sysSandVO);
                    vo.setSysSandVO(sysSandVO);
                    vo.setSandModel(sysSandVO.getType());
                }
            }

            // 设置粉煤灰数据
            if (entity.getFlyashId() != null) {
                SysFlyash sysFlyash = flyashMap.get(entity.getFlyashId());
                if (sysFlyash != null) {
                    SysFlyashVO sysFlyashVO = new SysFlyashVO();
                    BeanUtils.copyProperties(sysFlyash, sysFlyashVO);
                    vo.setSysFlyashVO(sysFlyashVO);
                    vo.setFlyModel(sysFlyashVO.getGrade());
                }
            }

            // 设置减水剂数据
            if (entity.getReducerId() != null) {
                SysWaterReducer sysWaterReducer = reducerMap.get(Long.valueOf(entity.getReducerId()));
                if (sysWaterReducer != null) {
                    AdditiveWaterReducerVO waterReducerVO = new AdditiveWaterReducerVO();
                    BeanUtils.copyProperties(sysWaterReducer, waterReducerVO);
                    vo.setAdditiveWaterReducerVO(waterReducerVO);
                    vo.setWaterReducerModel(waterReducerVO.getModel());

                }
            }

            // 设置增效剂数据
            if (entity.getAgentId() != null) {
                SysEfficiencyAgent sysEfficiencyAgent = efficiencyAgentMap.get(entity.getAgentId());
                if (sysEfficiencyAgent != null) {
                    SysEfficiencyAgentVO sysEfficiencyAgentVO = new SysEfficiencyAgentVO();
                    BeanUtils.copyProperties(sysEfficiencyAgent, sysEfficiencyAgentVO);
                    vo.setSysEfficiencyAgentVO(sysEfficiencyAgentVO);
                    vo.setAgentModel(sysEfficiencyAgent.getModel());

                }
            }

            // 设置矿粉数据
            if (entity.getPowderId() != null) {
                SysMineralPowder sysMineralPowder = mineralPowderMap.get(Long.valueOf(entity.getPowderId()));
                if (sysMineralPowder != null) {
                    SysMineralPowderVO sysMineralPowderVO = new SysMineralPowderVO();
                    BeanUtils.copyProperties(sysMineralPowder, sysMineralPowderVO);
                    vo.setMineralPowderVO(sysMineralPowderVO);
                    vo.setMineralPowderModel(sysMineralPowderVO.getModel());
                }
            }

            // 设置其他数据
            if (entity.getAdmixturesId() != null) {
                SysOtherAdmixtures sysOtherAdmixtures = otherAdmixturesMap.get(Long.valueOf(entity.getAdmixturesId()));
                if (sysOtherAdmixtures != null) {
                    SysOtherAdmixturesVO sysOtherAdmixturesVO = new SysOtherAdmixturesVO();
                    BeanUtils.copyProperties(sysOtherAdmixtures, sysOtherAdmixturesVO);
                    vo.setSysOtherAdmixturesVO(sysOtherAdmixturesVO);
                    vo.setOtherAdmixturesModel(sysOtherAdmixturesVO.getModel());
                }
            }

            // 设置膨胀剂数据
            if (entity.getSwellingagentId() != null) {
                SysSwellingagent sysSwellingagent = swellingagentMap.get(entity.getSwellingagentId().longValue());
                if (sysSwellingagent != null) {
                    SwellingagentVO swellingagentVO = new SwellingagentVO();
                    BeanUtils.copyProperties(sysSwellingagent, swellingagentVO);
                    vo.setSwellingagentVO(swellingagentVO);
                    vo.setSwellingagentModel(swellingagentVO.getModel());
                }
            }



            return vo;
        }).collect(Collectors.toList());

        // 返回处理后的结果列表
        return mechanicalList;
    }





//    @Override
//    public List<MechanicalPerformanceQueryVO> queryMistedMechanicalPerformance(MechanicalPerformanceQueryDTO mechanicalPerformanceQueryDTO) {
//        // Step 1: 调用 Mapper 获取查询结果
//        List<MechanicalPerformanceQueryVO> mechanicalPerformanceList = sysMechanicalPerformanceMapper.selectByCondition(mechanicalPerformanceQueryDTO);
//
//        // Step 2: 预加载相关数据，减少循环中查询，转换 Integer -> Long
//        Map<Long, SysWater> waterMap = waterService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysWater -> sysWater.getWaterId().longValue(),
//                        item-> item
//                ));
//
//  /*      List<SysWater> sysWaterList = waterService.list();
//        Map<Long, SysWater> waterMap = new HashMap<>();
//        for (SysWater sysWater : sysWaterList) {
//            waterMap.put(sysWater.getWaterId().longValue(), sysWater); // 将 WaterId 转为 Long 作为键
//        }*/
//
//
//
//        Map<Long, SysCement> cementMap = sysCementService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysCement -> sysCement.getCementId().longValue(),
//                        item -> item
//                ));
//
//        Map<Long, SysStone> stoneMap = sysStoneService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysStone -> sysStone.getStoneId().longValue(),
//                        item -> item
//                ));
//
//        Map<Long, SysSand> sandMap = sysSandService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysSand -> sysSand.getSandId().longValue(),
//                        item -> item
//                ));
//
//        Map<Long, SysFlyash> flyashMap = sysFlyashService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysFlyash -> sysFlyash.getFlyashId().longValue(),
//                        item -> item
//                ));
//
//        Map<Long, SysWaterReducer> reducerMap = sysWaterReducerService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysWaterReducer -> sysWaterReducer.getReducerId().longValue(),
//                        item -> item
//                ));
//
//        Map<Long, SysEfficiencyAgent> efficiencyAgentMap = sysEfficiencyAgent.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysEfficiencyAgent -> sysEfficiencyAgent.getAgentId().longValue(),
//                        item -> item
//                ));
//
//        Map<Long, SysMineralPowder> mineralPowderMap = sysMineralPowderService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysMineralPowder -> sysMineralPowder.getPowderId().longValue(),
//                        item -> item
//                ));
//
//        Map<Long, SysOtherAdmixtures> otherAdmixturesMap = sysOtherAdmixturesService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        sysOtherAdmixtures -> sysOtherAdmixtures.getAdmixturesId().longValue(),
//                        item -> item
//                ));
//
//             //膨胀剂
//        Map<Long, SysSwellingagent> swellingagentMap = sysSwellingagentService.list()
//                .stream()
//                .collect(Collectors.toMap(
//                        swellingagent -> swellingagent.getSwellingagentId().longValue(),
//                        item -> item
//                ));
//
//        // Step 3: 填充数据
//        List<MechanicalPerformanceQueryVO> mechanicalList = mechanicalPerformanceList.stream().map(entity -> {
//            MechanicalPerformanceQueryVO vo = new MechanicalPerformanceQueryVO();
//            BeanUtils.copyProperties(entity, vo);
//
//            // 设置水数据
//            if (entity.getWaterId() != null) {
//                SysWater sysWater = waterMap.get(entity.getWaterId());
//                if (sysWater != null) {
//                    SysWaterVO sysWaterVO = new SysWaterVO();
//                    BeanUtils.copyProperties(sysWater, sysWaterVO);
//                    vo.setWaterList(Collections.singletonList(sysWaterVO));
//                } else {
//                    vo.setWaterList(Collections.emptyList());
//                }
//            }
//
//            // 设置水泥数据
//            if (entity.getCementId() != null) {
//                SysCement sysCement = cementMap.get(entity.getCementId());
//                if (sysCement != null) {
//                    SysCementVO sysCementVO = new SysCementVO();
//                    BeanUtils.copyProperties(sysCement, sysCementVO);
//                    vo.setCementList(Collections.singletonList(sysCementVO));
//                } else {
//                    vo.setCementList(Collections.emptyList());
//                }
//            }
//
//            // 设置石头数据
//            if (entity.getStoneId() != null) {
//                SysStone sysStone = stoneMap.get(entity.getStoneId());
//                if (sysStone != null) {
//                    SysStoneVO sysStoneVO = new SysStoneVO();
//                    BeanUtils.copyProperties(sysStone, sysStoneVO);
//                    vo.setStoneList(Collections.singletonList(sysStoneVO));
//                } else {
//                    vo.setStoneList(Collections.emptyList());
//                }
//            }
//
//            // 设置砂数据
//            if (entity.getSandId() != null) {
//                SysSand sysSand = sandMap.get(entity.getSandId());
//                if (sysSand != null) {
//                    SysSandVO sysSandVO = new SysSandVO();
//                    BeanUtils.copyProperties(sysSand, sysSandVO);
//                    sysSandVO.setFineness(sysSand.getFineness());
//                    vo.setSandtList(Collections.singletonList(sysSandVO));
//                } else {
//                    vo.setSandtList(Collections.emptyList());
//                }
//            }
//
//            // 设置粉煤灰数据
//            if (entity.getFlyashId() != null) {
//                SysFlyash sysFlyash = flyashMap.get(entity.getFlyashId());
//                if (sysFlyash != null) {
//                    SysFlyashVO sysFlyashVO = new SysFlyashVO();
//                    BeanUtils.copyProperties(sysFlyash, sysFlyashVO);
//                    vo.setFlyashList(Collections.singletonList(sysFlyashVO));
//                } else {
//                    vo.setFlyashList(Collections.emptyList());
//                }
//            }
//
//            // 设置减水剂数据
//            if (entity.getReducerId() != null) {
//                SysWaterReducer sysWaterReducer = reducerMap.get(entity.getReducerId());
//                if (sysWaterReducer != null) {
//                    AdditiveWaterReducerVO waterReducerVO = new AdditiveWaterReducerVO();
//                    BeanUtils.copyProperties(sysWaterReducer, waterReducerVO);
//                    vo.setWaterReducerList(Collections.singletonList(waterReducerVO));
//                } else {
//                    vo.setWaterReducerList(Collections.emptyList());
//                }
//            }
//
//            // 设置增效剂数据
//            if (entity.getAgentId() != null) {
//                SysEfficiencyAgent sysEfficiencyAgent = efficiencyAgentMap.get(entity.getAgentId());
//                if (sysEfficiencyAgent != null) {
//                    SysEfficiencyAgentVO sysEfficiencyAgentVO = new SysEfficiencyAgentVO();
//                    BeanUtils.copyProperties(sysEfficiencyAgent, sysEfficiencyAgentVO);
//                    vo.setEfficiencyAgentList(Collections.singletonList(sysEfficiencyAgentVO));
//                } else {
//                    vo.setEfficiencyAgentList(Collections.emptyList());
//                }
//            }
//
//            // 设置矿粉数据
//            if (entity.getPowderId() != null) {
//                SysMineralPowder sysMineralPowder = mineralPowderMap.get(entity.getPowderId());
//                if (sysMineralPowder != null) {
//                    SysMineralPowderVO sysMineralPowderVO = new SysMineralPowderVO();
//                    BeanUtils.copyProperties(sysMineralPowder, sysMineralPowderVO);
//                    vo.setMineralList(Collections.singletonList(sysMineralPowderVO));
//                } else {
//                    vo.setMineralList(Collections.emptyList());
//                }
//            }
//
//            // 设置其他数据
//            if (entity.getAdmixturesId() != null) {
//                SysOtherAdmixtures sysOtherAdmixtures = otherAdmixturesMap.get(entity.getAdmixturesId());
//                if (sysOtherAdmixtures != null) {
//                    SysOtherAdmixturesVO sysOtherAdmixturesVO = new SysOtherAdmixturesVO();
//                    BeanUtils.copyProperties(sysOtherAdmixtures, sysOtherAdmixturesVO);
//                    vo.setOtherList(Collections.singletonList(sysOtherAdmixturesVO));
//                } else {
//                    vo.setOtherList(Collections.emptyList());
//                }
//            }
//
//            System.out.println(entity.getSwellingagentId());
//            //膨胀剂
//            if (entity.getSwellingagentId() != null) {
//                SysSwellingagent sysOtherAdmixtures = swellingagentMap.get(Long.valueOf(entity.getAdmixturesId()));
//                if (sysOtherAdmixtures != null) {
//
//                    SwellingagentVO swellingagentVO = new SwellingagentVO();
//                    BeanUtils.copyProperties(sysOtherAdmixtures, swellingagentVO);
//                    vo.setSwellingagentList(Collections.singletonList(swellingagentVO));
//                } else {
//                    vo.setSwellingagentList(Collections.emptyList());
//                }
//            }
//
//
//            return vo;
//        }).collect(Collectors.toList());
//
//        // 返回处理后的结果列表
//        return mechanicalList;
//    }













//    @Override
//    public List<MechanicalPerformanceQueryVO> queryMistedMechanicalPerformance(MechanicalPerformanceQueryDTO mechanicalPerformanceQueryDTO) {
//
//        // Step 1: 调用 Mapper 获取查询结果
//        List<MechanicalPerformanceQueryVO> mechanicalPerformanceList = sysMechanicalPerformanceMapper.selectByCondition(mechanicalPerformanceQueryDTO);
//
//        // Step 2: 填充水数据
//        mechanicalPerformanceList = mechanicalPerformanceList.stream().map(entity -> {
//            MechanicalPerformanceQueryVO vo = new MechanicalPerformanceQueryVO();
//            Long waterId = entity.getWaterId();
//            System.out.println("水id"+waterId);
//            // 水数据查询逻辑
//            if (entity.getWaterId() != null) {
//                // 记录 waterId 值用于调试
//                System.out.println("查询 waterId: " + entity.getWaterId());
//
//                LambdaQueryWrapper<SysWater> wrapper = new LambdaQueryWrapper<>();
//                wrapper.eq(SysWater::getWaterId, entity.getWaterId());
//                List<SysWater> list = waterService.list(wrapper);
//
//                // 检查查询结果
//                if (!list.isEmpty()) {
//                    SysWater sysWater = list.get(0);
//                    SysWaterVO sysWaterVO = new SysWaterVO();
//                    BeanUtils.copyProperties(sysWater, sysWaterVO);
//
//                    // 将查询到的水数据包装成 List 并设置到 VO 中
//                    vo.setWaterList(Collections.singletonList(sysWaterVO));
//                } else {
//                    // 没有找到对应的水数据，设置为空列表
//                    System.out.println("没有找到对应的水数据，waterId: " + entity.getWaterId());
//                    vo.setWaterList(Collections.emptyList());
//                }
//            } else {
//                // 如果没有 waterId，设置为空列表
//                vo.setWaterList(Collections.emptyList());
//            }
//
//            // 复制其他属性
//            List<SysWaterVO> waterList = vo.getWaterList();
//            BeanUtils.copyProperties(entity, vo);
//            vo.setWaterList(waterList);
//            return vo;
//        }).collect(Collectors.toList());
//
//        // 返回处理后的结果列表
//        return mechanicalPerformanceList;
//    }





/*    @Override
    public List<MechanicalPerformanceQueryVO> queryMistedMechanicalPerformance(MechanicalPerformanceQueryDTO mechanicalPerformanceQueryDTO) {

        // Step 1: 调用 Mapper 获取查询结果
        List<MechanicalPerformanceQueryVO> mechanicalPerformanceList = sysMechanicalPerformanceMapper.selectByCondition(mechanicalPerformanceQueryDTO);


        // Step 2: 填充水数据
        List<MechanicalPerformanceQueryVO>  mechanicalList = mechanicalPerformanceList.stream().map(entity -> {
            MechanicalPerformanceQueryVO vo = new MechanicalPerformanceQueryVO();
            // 复制其他属性
            BeanUtils.copyProperties(entity, vo);

            // 水数据查询逻辑
            if (entity.getWaterId() != null) {
                LambdaQueryWrapper<SysWater> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysWater::getWaterId, entity.getWaterId());
                List<SysWater> list = waterService.list(wrapper);
                if(!list.isEmpty()){
                    SysWater sysWater = list.get(0);
                    SysWaterVO sysWaterVO = new SysWaterVO();
                    BeanUtils.copyProperties(sysWater, sysWaterVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setWaterList(Collections.singletonList(sysWaterVO));
                }else {
                // 如果没有 waterId，设置为空列表
                vo.setWaterList(Collections.emptyList());
            }

            }
            //水泥表模糊查询
            if (entity.getCementId()!= null) {
                LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysCement::getCementId, entity.getCementId());
                List<SysCement> list = sysCementService.list(wrapper);
                if(!list.isEmpty()){
                    SysCement sysCement = list.get(0);
                    SysCementVO sysCementVO = new SysCementVO();
                    BeanUtils.copyProperties(sysCement, sysCementVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setCementList(Collections.singletonList(sysCementVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setCementList(Collections.emptyList());
                }

            }
            //石头模糊查询
            if (entity.getStoneId()!= null) {
                LambdaQueryWrapper<SysStone> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysStone::getStoneId, entity.getStoneId());
                List<SysStone> list = sysStoneService.list(wrapper);
                if(!list.isEmpty()){
                    SysStone sysCement = list.get(0);
                    SysStoneVO sysStoneVO = new SysStoneVO();
                    BeanUtils.copyProperties(sysCement, sysStoneVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setStoneList(Collections.singletonList(sysStoneVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setStoneList(Collections.emptyList());
                }

            }
            //砂
            if (entity.getSandId()!= null) {
                LambdaQueryWrapper<SysSand> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysSand::getSandId, entity.getSandId());
                List<SysSand> list = sysSandService.list(wrapper);
                if(!list.isEmpty()){
                    SysSand sysSand = list.get(0);
                    SysSandVO sysSandVO = new SysSandVO();
                    BeanUtils.copyProperties(sysSand, sysSandVO);
                    sysSandVO.setFineness(sysSand.getFineness());

                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setSandtList(Collections.singletonList(sysSandVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setSandtList(Collections.emptyList());
                }

            }
            //粉煤灰
            if (entity.getFlyashId()!= null) {
                LambdaQueryWrapper<SysFlyash> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysFlyash::getFlyashId, entity.getFlyashId());
                List<SysFlyash> list = sysFlyashService.list(wrapper);
                if(!list.isEmpty()){
                    SysFlyash sysFlyash = list.get(0);
                    //SysSandVO sysSandVO = new SysSandVO();
                    SysFlyashVO sysFlyashVO = new SysFlyashVO();
                    BeanUtils.copyProperties(sysFlyash, sysFlyashVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setFlyashList(Collections.singletonList(sysFlyashVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setFlyashList(Collections.emptyList());
                }

            }

            // 减水剂
            if (entity.getFlyashId()!= null) {
                LambdaQueryWrapper<SysWaterReducer> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysWaterReducer::getReducerId, entity.getReducerId());
                List<SysWaterReducer> list = sysWaterReducerService.list(wrapper);
                if(!list.isEmpty()){
                    SysWaterReducer sysWaterReducer = list.get(0);
                    //SysSandVO sysSandVO = new SysSandVO();
                    AdditiveWaterReducerVO waterReducerVO = new AdditiveWaterReducerVO();
                    BeanUtils.copyProperties(sysWaterReducer, waterReducerVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setWaterReducerList(Collections.singletonList(waterReducerVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setWaterReducerList(Collections.emptyList());
                }

            }
            //增效剂
            if (entity.getFlyashId()!= null) {
                LambdaQueryWrapper<SysEfficiencyAgent> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysEfficiencyAgent::getAgentId, entity.getAgentId());
                List<SysEfficiencyAgent> list = sysEfficiencyAgent.list(wrapper);
                if(!list.isEmpty()){
                    SysEfficiencyAgent sysEfficiencyAgent = list.get(0);
                    SysEfficiencyAgentVO sysEfficiencyAgentVO = new SysEfficiencyAgentVO();
                    BeanUtils.copyProperties(sysEfficiencyAgent, sysEfficiencyAgentVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setEfficiencyAgentList(Collections.singletonList(sysEfficiencyAgentVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setEfficiencyAgentList(Collections.emptyList());
                }

            }
            //矿粉
            if (entity.getFlyashId()!= null) {
                LambdaQueryWrapper<SysMineralPowder> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysMineralPowder::getPowderId, entity.getPowderId());
                List<SysMineralPowder> list = sysMineralPowderService.list(wrapper);

                if(!list.isEmpty()){
                    SysMineralPowder sysMineralPowder = list.get(0);
                    SysMineralPowderVO sysMineralPowderVO = new SysMineralPowderVO();
                    BeanUtils.copyProperties(sysMineralPowder, sysMineralPowderVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setMineralList(Collections.singletonList(sysMineralPowderVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setMineralList(Collections.emptyList());
                }

            }
            //其他
            if (entity.getAdmixturesId()!= null) {
                LambdaQueryWrapper<SysOtherAdmixtures> wrapper = new LambdaQueryWrapper<>();
                wrapper.eq(SysOtherAdmixtures::getAdmixturesId, entity.getAdmixturesId());
                List<SysOtherAdmixtures> list = sysOtherAdmixturesService.list(wrapper);

                System.out.println("你好好哈哈哈"+list);
                if(!list.isEmpty()){
                    SysOtherAdmixtures sysOtherAdmixtures = list.get(0);
                    //SysMineralPowderVO sysMineralPowderVO = new SysMineralPowderVO();
                    SysOtherAdmixturesVO sysOtherAdmixturesVO = new SysOtherAdmixturesVO();
                    BeanUtils.copyProperties(sysOtherAdmixtures, sysOtherAdmixturesVO);
                    // 将查询到的水数据包装成 List 并设置到 VO 中
                    vo.setOtherList(Collections.singletonList(sysOtherAdmixturesVO));
                }else {
                    // 如果没有 waterId，设置为空列表
                    vo.setOtherList(Collections.emptyList());
                }

            }

            return vo;
        }).collect(Collectors.toList());

        // 返回处理后的结果列表
        return mechanicalList;
    }*/




    /**
     * 查询
     * @param mechanicalIds
     * @return
     */
    @Override
    public List<SysMechanicalPerformance> exportMechanicalPerformance(List<Integer> mechanicalIds) {
        if (mechanicalIds == null || mechanicalIds.isEmpty()) {
            return Collections.emptyList();
        }
        List<SysMechanicalPerformance> sysMechanicalPerformanceList =sysMechanicalPerformanceMapper.exportMechanicalPerformance(mechanicalIds);

        return sysMechanicalPerformanceList;
    }





}
